package com.promise.jokerdream.model.knight

import kotlinx.serialization.Serializable

// 江湖长梦事件模型
@Serializable
data class KnightDreamEventModel(
    // 事件类型，1为奇遇、2为商店、3为战斗
    val type: Int = 0,
)

// 侠士长梦每天的动作
data class KnightDreamDayActionModel(
    // 命中事件等级之后再看index
    val index: Int = 0,
    // 事件等级
    val level: Int = 1,
    // 动作列表
    val actionList: List<String> = emptyList(),
)

// 侠士长梦副本的动作
data class KnightDreamActionModel(
    val adventureMap: Map<Int, KnightDreamDayActionModel> = emptyMap(),
    val fightMap: Map<Int, KnightDreamDayActionModel> = emptyMap(),
)

object KnightDreamMapping {

    val actionMap = mapOf(
        // 柒承的忙碌日常
        1 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("义不容辞", "清扫地板")
                ),
                3 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("义不容辞", "原木堆1")
                ),
                5 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("义不容辞", "清扫地板", "盛情难却")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("应聘")
                )
            ),
            fightMap = mapOf(
                1 to KnightDreamDayActionModel(
                    index = 1,
                    level = 1,
                ),
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                4 to KnightDreamDayActionModel(
                    level = 1,
                ),
                5 to KnightDreamDayActionModel(
                    level = 1
                )
            )
        ),
        // 技冠五绝，id为7，一条路走到黑
        // 群英拭剑谁为峰，id为32，一条路走到黑
        // 一骑红尘妃子笑
        37 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("佯装离去", "邀他喝酒")
                ),
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("上前搭话", "一口答应")
                ),
                3 to KnightDreamDayActionModel(
                    index = 1,
                    level = 1,
                    actionList = listOf("路线3", "盘问身份")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("题诗一首")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("上前搭话", "一口答应", "佯装离去", "邀他喝酒")
                ),
                7 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("题诗一首")
                ),
                9 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("上前搭话", "一口答应")
                ),
                10 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("上前搭话", "一口答应")
                )
            ),
            fightMap = mapOf(
                4 to KnightDreamDayActionModel(
                    level = 1
                ),
                8 to KnightDreamDayActionModel(
                    index = 2,
                    level = 1
                ),
                10 to KnightDreamDayActionModel(
                    level = 1
                )
            )
        ),
        // 南海有岛名侠客
        39 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("即刻前往")
                ),
                3 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("龙岛主", "岛中闲逛")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("采摘野果")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                4 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                )
            )
        ),
        // 绝世秘籍之争
        43 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("携手合作")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("尝试交谈", "借机休息")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("武学秘籍")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                5 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                )
            )
        ),
        // 老鹅的圣诞冒险
        44 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("喝口酒")
                ),
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("要挟清官")
                ),
                4 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("继续前行", "认真搜寻", "线路1", "大块朵颐", "出手制止")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("抓住麋鹿", "圣诞祝福", "转身离开")
                ),
                7 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("继续前行", "认真搜寻", "线路1")
                )
            ),
            fightMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 1
                ),
                2 to KnightDreamDayActionModel(
                    level = 1
                ),
                3 to KnightDreamDayActionModel(
                    index = 1,
                    level = 1
                ),
            )
        ),
        // 世外桃源梦一场
        45 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("向下望去", "小心探索")
                ),
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("找找吃的")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("过去看看", "分享食物")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("强势出手")
                )
            ),
            fightMap = mapOf(
                3 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2,
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                ),
            )
        ),
        // 中原武林之危
        46 to KnightDreamActionModel(
            adventureMap = mapOf(
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("进入山洞", "左岔路")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("挺身而出", "拿秘籍")
                ),
                7 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("继续赶路")
                )
            ),
            fightMap = mapOf(
                1 to KnightDreamDayActionModel(
                    index = 2,
                    level = 2
                ),
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                3 to KnightDreamDayActionModel(
                    index = 2,
                    level = 2
                ),
                4 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                5 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                6 to KnightDreamDayActionModel(
                    index = 2,
                    level = 2
                ),
                7 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
            )
        ),
        // 时空守护者
        47 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("上前询问", "一口答应")
                ),
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 1,
                    actionList = listOf("转一次")
                ),
                3 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("解释身份", "题诗一首")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("原地思考", "默默低语")
                ),
                6 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("转一次", "漩涡1")
                ),
                7 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("原地思考", "默默低语", "解释身份", "题诗一首")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 1
                ),
                4 to KnightDreamDayActionModel(
                    index = 2
                ),
                7 to KnightDreamDayActionModel(
                    level = 2
                ),
                8 to KnightDreamDayActionModel(
                    level = 2
                )
            )
        ),
        // 倚天屠龙归我心
        48 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("前辈")
                ),
                3 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("开始回忆")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("回首掏")
                ),
                7 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("远远观望")
                ),
                8 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("独自神伤")
                )
            ),
            fightMap = mapOf(
                3 to KnightDreamDayActionModel(
                    level = 2
                ),
                4 to KnightDreamDayActionModel(
                    level = 2
                ),
                5 to KnightDreamDayActionModel(
                    level = 2
                ),
                6 to KnightDreamDayActionModel(
                    level = 2
                )
            )
        ),
        // 神雕侠侣
        49 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("笼络侠客")
                ),
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
            )
        ),
        // 雪山藏魂
        50 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("捉迷藏")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("尝试交谈", "询问大侠")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("刀剑归真")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                5 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                )
            )
        ),
        // 桃花自古笑春风
        51 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("过去看看", "以西湖来对")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("我的")
                ),
                7 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("摸黑进入", "纯路人")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    index = 2,
                    level = 2,
                ),
                3 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                4 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
            )
        ),
        // 战乱襄阳
        52 to KnightDreamActionModel(
            adventureMap = mapOf(
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("一枚金针")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("向左突围", "周遭探查", "捣鼓粮仓")
                ),
                6 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("拿出金针")
                )
            ),
            fightMap = mapOf(
                3 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
                5 to KnightDreamDayActionModel(
                    index = 1,
                    level = 2
                ),
            )
        ),
        // 天涯浪子
        53 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("问起身份", "锦囊2")
                ),
                2 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("重金求见", "相约明日")
                ),
                3 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("阁楼3")
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("结为姐弟")
                ),
                5 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("筹备计划", "是")
                ),
                6 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("锦囊1")
                )
            ),
            fightMap = mapOf(
                7 to KnightDreamDayActionModel(
                    index = 1,
                    level = 1
                ),
                8 to KnightDreamDayActionModel(
                    level = 2,
                )
            )
        ),
        // 全真古墓意难平
        54 to KnightDreamActionModel(
            adventureMap = mapOf(
                1 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("宅家乐斗")
                ),
                2 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("全真剑法")
                ),
                3 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("环顾四周", "切磋武功")
                ),
                5 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("暂且撤退")
                ),
                6 to KnightDreamDayActionModel(
                    level = 1,
                    actionList = listOf("暂且撤退")
                ),
                7 to KnightDreamDayActionModel(
                    level = 2,
                    actionList = listOf("坚持本心", "李莫愁")
                )
            ),
            fightMap = mapOf(
                2 to KnightDreamDayActionModel(
                    level = 1
                ),
                4 to KnightDreamDayActionModel(
                    level = 2,
                ),
                5 to KnightDreamDayActionModel(
                    level = 1,
                ),
                6 to KnightDreamDayActionModel(
                    level = 1,
                ),
                8 to KnightDreamDayActionModel(
                    level = 2,
                ),
            )
        )
    )
    
    /**
     * 根据id和当前天数获取对应的KnightDreamDayActionModel
     * @param id 副本id
     * @param currentDay 当前天数
     * @param isAdventure 是否为奇遇事件，true为奇遇，false为战斗
     * @return 对应的KnightDreamDayActionModel，如果不存在返回null
     */
    fun getKnightDreamDayActionModel(id: Int, currentDay: Int, isAdventure: Boolean): KnightDreamDayActionModel? {
        val actionModel = actionMap[id] ?: return null
        
        return if (isAdventure) {
            // 奇遇
            actionModel.adventureMap[currentDay]
        } else {
            // 战斗
            actionModel.fightMap[currentDay]
        }
    }
}
